package com.hdjk.view.callback;

import com.hdjk.view.entity.CustomFundEntity;
import com.lst.projectlib.entity.Msg;

import org.json.JSONObject;

import okhttp3.Response;

/**
 * Created by sxy on 2017/11/2.
 */

public abstract class CustomFundDetailCallBack extends MsgCallBack {
    @Override
    public Msg parseNetworkResponse(Response response, int i) throws Exception {
        Msg msg = super.parseNetworkResponse(response, i);
        JSONObject jsonObject = (JSONObject) msg.getData();
        if (jsonObject!=null) {
            CustomFundEntity entity = new CustomFundEntity();
            if (!jsonObject.isNull("FundName")) {
                entity.setFundName(jsonObject.getString("FundName"));
            }
            if (!jsonObject.isNull("FundCode")) {
                entity.setFundCode(jsonObject.getString("FundCode"));
            }
            if (!jsonObject.isNull("FundCustodian")) {
                entity.setFundCustodian(jsonObject.getString("FundCustodian"));
            }
            if (!jsonObject.isNull("Remark")) {
                entity.setRemark(jsonObject.getString("Remark"));
            }
            if (!jsonObject.isNull("CreateTime")) {
                entity.setCreateTime(jsonObject.getString("CreateTime"));
            }
            if (!jsonObject.isNull("ModifyTime")) {
                entity.setModifyTime(jsonObject.getString("ModifyTime"));
            }
            if (!jsonObject.isNull("Hidden")) {
                entity.setHidden(jsonObject.getBoolean("Hidden"));
            }
            if (!jsonObject.isNull("State")) {
                entity.setState(jsonObject.getString("State"));
            }
            if (!jsonObject.isNull("ExtAttrs")) {
                entity.setExtAttrs(jsonObject.getString("ExtAttrs"));
            }
            if (!jsonObject.isNull("Imgs")) {
                entity.setImgs(jsonObject.getString("Imgs"));
            }
            if (!jsonObject.isNull("MinInitialIpoAmount")) {
                entity.setMinInitialIpoAmount(jsonObject.getString("MinInitialIpoAmount"));
            }
            if (!jsonObject.isNull("EndDate")) {
                entity.setEndDate(jsonObject.getString("EndDate"));
            }
            if (!jsonObject.isNull("LaunchDate")) {
                entity.setLaunchDate(jsonObject.getString("LaunchDate"));
            }
            if (!jsonObject.isNull("InvestmentObjective")) {
                entity.setInvestmentObjective(jsonObject.getString("InvestmentObjective"));
            }
            if (!jsonObject.isNull("FundType")) {
                entity.setFundType(jsonObject.getString("FundType"));
            }
            if (!jsonObject.isNull("LaunchSize")) {
                double size=jsonObject.getDouble("LaunchSize");
                entity.setLaunchSize(size/100000000+"");
            }
            if (!jsonObject.isNull("MinSubseqIpoAmount")) {
                entity.setMinSubseqIpoAmount(jsonObject.getString("MinSubseqIpoAmount"));
            }
            if (!jsonObject.isNull("IpoStartDate")) {
                entity.setIpoStartDate(jsonObject.getString("IpoStartDate"));
            }
            if (!jsonObject.isNull("UpdateTime")) {
                entity.setUpdateTime(jsonObject.getString("UpdateTime"));
            }
            if (!jsonObject.isNull("Id")) {
                entity.setId(jsonObject.getString("Id"));
            }
            msg.setData(entity);
        }
        return msg;
    }
}
